﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link rel="stylesheet" href="../style/css/user/login.css">
    <script src="../style/js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
    <script>
        function login() {
            $.post("../user/login", $("#loginForm").serialize(), function (res) {

                    if ((res.code === 200 && res.data.state === 0) || (res.code === 200 && res.data.state === 1) ) {
                        window.sessionStorage.setItem("userId", res.data.id);
                        window.sessionStorage.setItem("userNickName", res.data.nickName);
                        window.sessionStorage.setItem("userState", res.data.state);
                        if (res.data.newFiLeName !== '' && res.data.newFiLeName !== null) {
                            window.sessionStorage.setItem("userNewFiLeName", res.data.newFileName);
                        }
                        location.replace("../front/index.html");
                    } else if (res.code === 200 && res.data.state === 2) {
                        alert("您的账号已被禁用")
                    } else if (res.code === 201 || res.code === 500) {
                        alert(res.msg);
                    } else {
                        alert("登录失败");
                    }
                }

                ,
                "json"
            )
        }
    </script>
</head>
<body>
<div class="container">
    <form id="loginForm">
        <div class="login-form">
            <div class="text">登录</div>
            <div class="form-item">
                <input type="text" name="account" placeholder="用户名">
                <input type="password" name="password" placeholder="密码">
            </div>
            <div class="btn" onclick="login()">登录</div>
            <div class="btn-back"></div>
            <div class="other">
                没有账号？<a href="user_register.html">去注册</a>
            </div>
        </div>
    </form>
</div>

</body>
</html>
